﻿using Microsoft.Practices.Prism.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;

namespace WebServerConnectorDll
{
    [DataContract]
    public class CUser : NotificationObject, IFruitClass
    {
        private bool    isChoose;
        private String  uid;
        private String  name;
        private String  username;
        private String  password;
        private int     officeUID;
        private String  officeName;
        private int     cityUID;
        private String  cityName;
        private int     provinceUID;
        private String  provinceName;
        private int     integral;
        private int     defAddressUID;
        private String  address;
        private String  coupon;

        public bool IsChoose
        {
            get
            {
                return isChoose;
            }
            set
            {
                isChoose = value;
                RaisePropertyChanged("IsChoose");
            }
        }

        [DataMember(Order = 0)]
        public String UID
        {
            get
            {
                return uid;
            }
            set
            {
                uid = value;
                RaisePropertyChanged("UID");
            }
        }

        [DataMember(Order = 1)]
        public String Name
        {
            get
            {
                return name;
            }
            set
            {
                name = value;
                RaisePropertyChanged("Name");
            }
        }

        [DataMember(Order = 2)]
        public String Username
        {
            get
            {
                return username;
            }
            set
            {
                username = value;
                RaisePropertyChanged("UserName");
            }
        }

        [DataMember(Order = 3)]
        public String Password
        {
            get
            {
                return password;
            }
            set
            {
                password = value;
                RaisePropertyChanged("Password");
            }
        }

        [DataMember(Order = 4)]
        public int OfficeUID
        {
            get
            {
                return officeUID;
            }
            set
            {
                officeUID = value;
                RaisePropertyChanged("OfficeUID");
            }
        }

        [DataMember(Order = 4)]
        public String OfficeName
        {
            get
            {
                return officeName;
            }
            set
            {
                officeName = value;
                RaisePropertyChanged("OfficeName");
            }
        }

        [DataMember(Order = 5)]
        public int CityUID
        {
            get
            {
                return cityUID;
            }
            set
            {
                cityUID = value;
                RaisePropertyChanged("CityUID");
            }
        }

        [DataMember(Order = 5)]
        public String CityName
        {
            get
            {
                return cityName;
            }
            set
            {
                cityName = value;
                RaisePropertyChanged("CityName");
            }
        }

        [DataMember(Order = 6)]
        public int ProvinceUID
        {
            get
            {
                return provinceUID;
            }
            set
            {
                provinceUID = value;
                RaisePropertyChanged("ProvinceUID");
            }
        }

        [DataMember(Order = 6)]
        public String ProvinceName
        {
            get
            {
                return provinceName;
            }
            set
            {
                provinceName = value;
                RaisePropertyChanged("ProvinceName");
            }
        }

        [DataMember(Order = 7)]
        public int Integral
        {
            get
            {
                return integral;
            }
            set
            {
                integral = value;
                RaisePropertyChanged("Integral");
            }
        }

        [DataMember(Order = 8)]
        public int DefAddressUID
        {
            get
            {
                return defAddressUID;
            }
            set
            {
                defAddressUID = value;
                RaisePropertyChanged("DefAddressUID");
            }
        }

        [DataMember(Order = 8)]
        public String Address
        {
            get
            {
                return address;
            }
            set
            {
                address = value;
                RaisePropertyChanged("Address");
            }
        }

        [DataMember(Order = 9)]
        public String Coupon
        {
            get
            {
                return coupon;
            }
            set
            {
                coupon = value;
                RaisePropertyChanged("Coupon");
            }
        }

        public CUser(String pUID, String pName, String pUsername, String pPassword, int pOfficeUID, int pIntegral,int pDefAddressUID)
        {
            UID = pUID;
            Name = pName;
            Username = pUsername;
            Password = pPassword;
            OfficeUID = pOfficeUID;
            Integral = pIntegral;
            DefAddressUID = pDefAddressUID;
        }

        public String ToInsertString()
        {
            return "\'" + UID + "\'-\'" + Name + "\'-\'" + Username + "\'-\'" + Password + "\'-\'" + OfficeUID + "\'-\'" + Integral + "\'-\'" + DefAddressUID + "\'";
        }

        public String ToUpdateString()
        {
            return "Name=\'" + Name + "\',Username=\'" + Username + "\',Password=\'" + Password + "\',OfficeUID=\'" + OfficeUID + "\',Integral=\'" + Integral + "\',DefAddressUID=\'" + DefAddressUID + "\'";
        }
    }
}
